/*
 * Copyright 2023, Haiku, Inc. All rights reserved.
 * Distributed under the terms of the MIT License.
 */

#include <asm_defs.h>

/*
 * LoongArch64 ABI规范：
 * - 参数传递使用a0-a7寄存器
 * - 返回值使用a0寄存器
 * - 系统调用号放在a7寄存器中
 * - 系统调用使用syscall指令
 */

#define _SYSCALL(name, n) \
	.align 4; \
	FUNCTION(name): \
		li.d	a7, n; \
		syscall	0; \
		ret; \
	FUNCTION_END(name)

/* 定义不同参数数量的系统调用宏 */
#define SYSCALL0(name, n)	_SYSCALL(name, n)
#define SYSCALL1(name, n)	_SYSCALL(name, n)
#define SYSCALL2(name, n)	_SYSCALL(name, n)
#define SYSCALL3(name, n)	_SYSCALL(name, n)
#define SYSCALL4(name, n)	_SYSCALL(name, n)
#define SYSCALL5(name, n)	_SYSCALL(name, n)
#define SYSCALL6(name, n)	_SYSCALL(name, n)
#define SYSCALL7(name, n)	_SYSCALL(name, n)
#define SYSCALL8(name, n)	_SYSCALL(name, n)
#define SYSCALL9(name, n)	_SYSCALL(name, n)
#define SYSCALL10(name, n)	_SYSCALL(name, n)
#define SYSCALL11(name, n)	_SYSCALL(name, n)
#define SYSCALL12(name, n)	_SYSCALL(name, n)
#define SYSCALL13(name, n)	_SYSCALL(name, n)
#define SYSCALL14(name, n)	_SYSCALL(name, n)
#define SYSCALL15(name, n)	_SYSCALL(name, n)
#define SYSCALL16(name, n)	_SYSCALL(name, n)
#define SYSCALL17(name, n)	_SYSCALL(name, n)
#define SYSCALL18(name, n)	_SYSCALL(name, n)
#define SYSCALL19(name, n)	_SYSCALL(name, n)
#define SYSCALL20(name, n)	_SYSCALL(name, n)